import React from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import type { RootStackParamList } from '../types/navigation';

const TestCarDetail: React.FC = () => {
  const navigation = useNavigation<ReactNavigation.RootParamList>();

  const testCarId = '68a026af52e389ea62b2c0b1'; // 使用数据库中的实际车辆ID

  const handleNavigateToDetail = () => {
    navigation.navigate('CarDetail', { carId: testCarId });
  };

  return (
    <View style={styles.container}>
      <Text style={styles.title}>车辆详情页测试</Text>
      <Text style={styles.description}>
        点击下面的按钮测试车辆详情页功能
      </Text>
      
      <TouchableOpacity style={styles.button} onPress={handleNavigateToDetail}>
        <Text style={styles.buttonText}>查看车辆详情</Text>
      </TouchableOpacity>
      
      <View style={styles.infoContainer}>
        <Text style={styles.infoTitle}>测试说明：</Text>
        <Text style={styles.infoText}>• 确保后端服务器正在运行</Text>
        <Text style={styles.infoText}>• 确保数据库中有车辆数据</Text>
        <Text style={styles.infoText}>• 测试车辆ID: {testCarId}</Text>
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    padding: 20,
    backgroundColor: '#f8f9fa',
  },
  title: {
    fontSize: 24,
    fontWeight: 'bold',
    color: '#333',
    marginBottom: 16,
  },
  description: {
    fontSize: 16,
    color: '#666',
    textAlign: 'center',
    marginBottom: 32,
  },
  button: {
    backgroundColor: '#007AFF',
    paddingHorizontal: 32,
    paddingVertical: 16,
    borderRadius: 12,
    marginBottom: 32,
  },
  buttonText: {
    color: 'white',
    fontSize: 18,
    fontWeight: 'bold',
  },
  infoContainer: {
    backgroundColor: 'white',
    padding: 20,
    borderRadius: 12,
    width: '100%',
  },
  infoTitle: {
    fontSize: 18,
    fontWeight: 'bold',
    color: '#333',
    marginBottom: 12,
  },
  infoText: {
    fontSize: 14,
    color: '#666',
    marginBottom: 8,
  },
});

export default TestCarDetail; 